﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Person;
using BrokerBase.Lib.Policy;

namespace broker.duty.YG
{
    class Class19
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"];

            int receiveAge = int.Parse(s.Substring(0, 2));

            if (ppa.Age >= receiveAge)
            {

                string t = ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("年金领取方式").ToString();

                double amt = ppa.Amount;

                SexType sexType = ppa.SchemePeriodActing.SchemeActing.Scheme.InsurantSex;

                if (t.Trim() == "按年领取")
                {
                    double val = 0.0d;

                    double baseamt = amt / 1000;

                    switch (receiveAge)
                    {
                        case 40:
                            val = sexType == SexType.Fmale ? baseamt * 35 : baseamt * 37;
                            break;
                        case 45:
                            val = sexType == SexType.Fmale ? baseamt * 38 : baseamt * 39;
                            break;
                        case 50:
                            val = sexType == SexType.Fmale ? baseamt * 40 : baseamt * 42;
                            break;
                        case 55:
                            val = sexType == SexType.Fmale ? baseamt * 44 : baseamt * 46;
                            break;
                        case 60:
                            val = sexType == SexType.Fmale ? baseamt * 48 : baseamt * 51;
                            break;
                        case 65:
                            val = sexType == SexType.Fmale ? baseamt * 53 : baseamt * 57;
                            break;
                        case 70:
                            val = sexType == SexType.Fmale ? baseamt * 60 : baseamt * 64;
                            break;
                    }

                    da.Value = val;
                }
                else
                {
                    da.Value = amt;
                    ppa.IsCurrentFinish = true;
                }
            }

        }


        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                double rec = ppa.GetDutyTotalValue("年金给付");

                da.Value = ppa.Amount - rec;

                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("生命末期"))
            {
                double rec = ppa.GetDutyTotalValue("年金给付");

                da.Value = ppa.Amount - rec;

                ppa.IsCurrentFinish = true;
            }
        }
    }
}
